{extend name="$base" /}
{block name="main"}
<div class="set-style">
	<div class="set-item">
		<dl>
			<dt>点赞送银币：</dt>
			<dd>
				<p><input id="click_point" type="number" value="{$reward_rule_info.click_point}" min="0"  onkeyup="value=value.replace(/[^\d+]/g,'')" class="input-common harf" ><em class="unit">分</em></p>
			</dd>
		</dl>
		<dl>
			<dt>点赞送优惠券：</dt>
			<dd>
				<select class="row-no-radius select-common" id="click_coupon">
					<option value="">请选择优惠券种类</option>
					{foreach name="$coupon_list" item="v"}
					{if condition="$v['coupon_type_id'] == $reward_rule_info['click_coupon']"}
					<option value="{$v.coupon_type_id}" selected="selected">{$v.coupon_name}</option>
					{else/}
					<option value="{$v.coupon_type_id}">{$v.coupon_name}</option>
					{/if}
					{/foreach}
				</select>
			</dd>
		</dl>
		<dl>
			<dt></dt>
			<dd>
				<p>
					<input id="click_coupon_open" type="checkbox" onchange="setMemberActionConfig();" class="checkbox" {if condition="$member_action_config['click_coupon'] eq 1"}checked="checked"{/if}>
				</p>
				<p class="hint">是否启用点赞送优惠券</p>
			</dd>
		</dl>
	</div>
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="save();" style="margin:20px 0 20px 205px;">保存</button>
		</dd>
	</dl>
</div>
<script>
function setMemberActionConfig(){
	if($("#click_coupon_open").prop("checked")){
		var click_coupon_open = 1;
	}else{
		var click_coupon_open = 0;
	}
	$.ajax({
		type : 'post',
		url : "{:__URL('__URL__/NsMemberPraise/ADMIN_MODULE/MemberPraise/setMemberActionConfig')}",
		data : { 'click_coupon':click_coupon_open },
		success : function(data){
			//alert(JSON.stringify(data));
		}
	})
}

function save() {
	var click_point = $("#click_point").val();
	var click_coupon = $("#click_coupon").val();
	if ($("#click_coupon_open").prop("checked")) {
		if (click_coupon == "") {
			showMessage("error", "请选择优惠券种类");
			return;
		}
	}
	$.ajax({
		type: 'post',
		url : "{:__URL('__URL__/NsMemberPraise/ADMIN_MODULE/MemberPraise/index')}",
		data: {
			"click_point": click_point,
			'click_coupon': click_coupon
		},
		success: function (data) {
			if (data['code'] >= 0) {
				showMessage("success", "设置成功！", "{:__URL('__URL__/NsMemberPraise/ADMIN_MODULE/MemberPraise/index')}");
			} else {
				showMessage("error", "设置失败");
			}
		}
	});
}
</script>
{/block}
